package cn.xugongwei.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 教师类
 *
 * @author xugongwei (isxugongwei(a)gmail.com)
 * @date 2019/5/28 9:06
 */
@Data
@AllArgsConstructor
public class Teacher implements Comparable {
    /**
     * 老师id
     */
    private Integer id;

    /**
     * 老师姓名
     */
    private String name;

    /**
     * 老师年龄
     */
    private Integer age;

    /**
     * 重写Comparable接口的compareTo方法，设置排序规则
     *
     * @param object 对象
     * @return
     */
    @Override
    public int compareTo(Object object) {
        Teacher student = (Teacher) object;
        // 年龄从大到小排序
        return student.getAge() - this.age;
    }
}
